<?php

class LoginData_Data {
	
	private $db;
	
	public function __construct(){
		$this->db = new MysqlImproved_Driver;
	}
	
	
	public function getLinksData(){
		$this->db->connect();
		$this->db->prepare(
				"
				SELECT
				category_settings.category_sitename,
				category_settings.module_sitename,
				category_settings.category_siteurl,
				meta_category.category_link_title,
				meta_category.category_link_alt
				FROM
				category_settings
				INNER JOIN
				meta_category
				ON
				category_settings.category_sitename = meta_category.category_sitename
				WHERE
				category_settings.module_sitename = 'Login'
				AND 
				category_settings.category_siteonline = '1'
				;
				"
				);
		$this->db->query();
		$articleLinks = "";
		while($articleLinkData = $this->db->fetch('array')){
			$articleLinks .='<li><a title="';
			$articleLinks .= $articleLinkData['category_link_title'];
			$articleLinks .= '" alt="';
			$articleLinks .= $articleLinkData['category_link_alt'];
			$articleLinks .= '" href="';
			$articleLinks .= SITE_ROOT . '/' . strtolower($articleLinkData['module_sitename']) . '/' . $articleLinkData['category_siteurl'];
			$articleLinks .= '" rel="external">';
			$articleLinks .= $articleLinkData['category_sitename'];
			$articleLinks .= "</a></li>";
		}
		return $articleLinks;
	}
	
	public function getPageData(){
		$this->db->connect();
		$this->db->prepare(
				"
				SELECT
				modules_settings.module_sitename,
				modules_settings.module_siteurl,
				modules_settings.module_templatename,
				modules_settings.module_access_level,
				meta_modules.module_meta_keywords,
				meta_modules.module_meta_description,
				meta_modules.module_meta_title,
				meta_modules.module_link_title,
				meta_modules.module_link_alt,
				content_modules.module_title,
				content_modules.module_description,
				content_modules.module_content
				FROM
				modules_settings,
				meta_modules,
				content_modules
				WHERE
				modules_settings.module_sitename = 'Login'
				AND
				modules_settings.module_sitename = meta_modules.module_sitename
				AND
				modules_settings.module_sitename = content_modules.module_sitename
				AND 
				content_modules.module_sitename = 'Login'
				AND 
				meta_modules.module_sitename = 'Login'
				LIMIT
				1
				; 
				"
				);
		$this->db->query();
		$article = $this->db->fetch('array');
		return $article;
	}
	
	public function isOnline(){
		$this->db->connect();
		$this->db->prepare(
				"
				SELECT
				meta_modules.module_sitename,
				modules_settings.module_siteonline
				FROM
				modules_settings
				INNER JOIN meta_modules ON modules_settings.module_sitename = meta_modules.module_sitename
				WHERE
				modules_settings.module_sitename = 'Login'
				AND
				modules_settings.module_siteonline = '1'
				;
				"
				);
		return $this->db->query();
		
	}
	
	
	
}